﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGiVariant : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGiVariant(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGiVariant_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGiVariant obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGiVariant()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGiVariant(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdGiVariant cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiVariant_cast(OdRxObject.getCPtr(pObj));
			OdGiVariant result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiVariant_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiVariant_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiVariant_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiVariant createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiVariant_createObject__SWIG_0();
			OdGiVariant result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiVariant createObject(OdGiVariant value)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiVariant_createObject__SWIG_1(OdGiVariant.getCPtr(value));
			OdGiVariant result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiVariant createObject(bool value)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiVariant_createObject__SWIG_2(value);
			OdGiVariant result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiVariant createObject(int value)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiVariant_createObject__SWIG_3(value);
			OdGiVariant result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiVariant createObject(double value)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiVariant_createObject__SWIG_4(value);
			OdGiVariant result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiVariant createObject(OdCmEntityColor value)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiVariant_createObject__SWIG_5(OdCmEntityColor.getCPtr(value));
			OdGiVariant result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiVariant createObject(string value)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiVariant_createObject__SWIG_6(value);
			OdGiVariant result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool IsEqual(OdGiVariant value)
		{
			bool result = GlobalsPINVOKE.OdGiVariant_IsEqual(this.swigCPtr, OdGiVariant.getCPtr(value));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGiVariant Assign(OdGiVariant value)
		{
			OdGiVariant result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiVariant_Assign(this.swigCPtr, OdGiVariant.getCPtr(value)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void copyFrom(OdRxObject pSource)
		{
			GlobalsPINVOKE.OdGiVariant_copyFrom(this.swigCPtr, OdRxObject.getCPtr(pSource));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGiVariant.VariantType type()
		{
			OdGiVariant.VariantType result = (OdGiVariant.VariantType)GlobalsPINVOKE.OdGiVariant_type(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void set(bool value)
		{
			GlobalsPINVOKE.OdGiVariant_set__SWIG_0(this.swigCPtr, value);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void set(int value)
		{
			GlobalsPINVOKE.OdGiVariant_set__SWIG_1(this.swigCPtr, value);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void set(double value)
		{
			GlobalsPINVOKE.OdGiVariant_set__SWIG_2(this.swigCPtr, value);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void set(OdCmEntityColor value)
		{
			GlobalsPINVOKE.OdGiVariant_set__SWIG_3(this.swigCPtr, OdCmEntityColor.getCPtr(value));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void set(string value)
		{
			GlobalsPINVOKE.OdGiVariant_set__SWIG_4(this.swigCPtr, value);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool asBoolean()
		{
			bool result = GlobalsPINVOKE.OdGiVariant_asBoolean(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public int asInt()
		{
			int result = GlobalsPINVOKE.OdGiVariant_asInt(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public double asDouble()
		{
			double result = GlobalsPINVOKE.OdGiVariant_asDouble(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdCmEntityColor asColor()
		{
			OdCmEntityColor result = new OdCmEntityColor(GlobalsPINVOKE.OdGiVariant_asColor(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public string asString()
		{
			string result = GlobalsPINVOKE.OdGiVariant_asString(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public float asFloat()
		{
			float result = GlobalsPINVOKE.OdGiVariant_asFloat(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public sbyte asChar()
		{
			sbyte result = GlobalsPINVOKE.OdGiVariant_asChar(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public byte asUchar()
		{
			byte result = GlobalsPINVOKE.OdGiVariant_asUchar(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public short asShort()
		{
			short result = GlobalsPINVOKE.OdGiVariant_asShort(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public ushort asUshort()
		{
			ushort result = GlobalsPINVOKE.OdGiVariant_asUshort(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public uint asUint()
		{
			uint result = GlobalsPINVOKE.OdGiVariant_asUint(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public int asLong()
		{
			int result = GlobalsPINVOKE.OdGiVariant_asLong(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public uint asUlong()
		{
			uint result = GlobalsPINVOKE.OdGiVariant_asUlong(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool getElem(string elem, OdGiVariant value)
		{
			bool result = GlobalsPINVOKE.OdGiVariant_getElem__SWIG_0(this.swigCPtr, elem, OdGiVariant.getCPtr(value));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGiVariant getElem(string elem)
		{
			OdGiVariant result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiVariant_getElem__SWIG_1(this.swigCPtr, elem), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setElem(string elem, OdGiVariant value)
		{
			GlobalsPINVOKE.OdGiVariant_setElem(this.swigCPtr, elem, OdGiVariant.getCPtr(value));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void deleteElem(string elem)
		{
			GlobalsPINVOKE.OdGiVariant_deleteElem(this.swigCPtr, elem);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public int getElemCount()
		{
			int result = GlobalsPINVOKE.OdGiVariant_getElemCount(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool getElemAt(int nElem, ref string elem, OdGiVariant value)
		{
			IntPtr intPtr = Marshal.StringToCoTaskMemUni(elem);
			IntPtr value2 = intPtr;
			bool result;
			try
			{
				bool flag = GlobalsPINVOKE.OdGiVariant_getElemAt__SWIG_0(this.swigCPtr, nElem, ref intPtr, OdGiVariant.getCPtr(value));
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				result = flag;
			}
			finally
			{
				if (intPtr != value2)
				{
					elem = Marshal.PtrToStringUni(intPtr);
				}
			}
			return result;
		}

		public OdGiVariant getElemAt(int nElem, ref string elem)
		{
			IntPtr intPtr = Marshal.StringToCoTaskMemUni(elem);
			IntPtr value = intPtr;
			OdGiVariant result;
			try
			{
				OdGiVariant odGiVariant = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiVariant_getElemAt__SWIG_1(this.swigCPtr, nElem, ref intPtr), false);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				result = odGiVariant;
			}
			finally
			{
				if (intPtr != value)
				{
					elem = Marshal.PtrToStringUni(intPtr);
				}
			}
			return result;
		}

		public static bool isEquivalent(OdGiVariant v1, OdGiVariant v2)
		{
			bool result = GlobalsPINVOKE.OdGiVariant_isEquivalent(OdGiVariant.getCPtr(v1), OdGiVariant.getCPtr(v2));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		public enum VariantType
		{
			kUndefined,
			kBoolean,
			kInt,
			kDouble,
			kColor,
			kString,
			kTable
		}
	}
}
